
/**
 * 本地储存模块封装 
 */
export const getItem = (name) => {
     const data = window.localStorage.getItem(name) 
     //为什么吧Json.parse 放在try catch
     //以为data 可能不是JSON 格式字符串
     try{
        //  尝试把data 转化为javaScript
        return JSON.parse(data)
     }catch(err){
        return 
     }
}
export const setItem = (name,value) => {
    
    if(typeof value === 'object'){
        value = JSON.stringify(value)
    }
     window.localStorage.setItem(name,value) 
}

export const removeItem =  name => {
    window.localStorage.removeItem(name)
}